package net.minhdiep.androiddialoglistener.view;
/*
 * User: Minh Diep
 * Date: 5/22/13
 * Time: 9:08 PM
 */

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;
import net.minhdiep.androiddialoglistener.R;


public class TwoButtons extends LinearLayout {

    OnButtonListener mListener;

    public TwoButtons(Context context, AttributeSet attrs){
        super(context, attrs);

        mListener = (OnButtonListener) context;

        LayoutInflater inflater = (LayoutInflater) context
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View view = inflater.inflate(R.layout.two_buttons, this);
        assert view != null;
        Button sayHelloBtn = (Button) view.findViewById(R.id.say_hello_btn);
        Button sayGoodbyeBtn = (Button) view.findViewById(R.id.say_goodbye_btn);
        sayHelloBtn.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View arg0) {
                mListener.onSayHelloBtnClick();
            }
        });

        sayGoodbyeBtn.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View arg0) {
                mListener.onSayGoodbyeBtnClick();
            }
        });
    }

    public interface OnButtonListener{
        public void onSayHelloBtnClick();
        public void onSayGoodbyeBtnClick();
    }
}
